// router - intex.ts
// import { storeToRefs } from 'pinia'
// import { loginStore } from '@/store/login'
// append import
import newsRoutes from './modules/newsRouter'
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/user',
    meta: { title: '授权登录', showNavbar: true },
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('@/views/home/index.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/login.vue'),
    meta: { title: '授权登录', showNavbar: true },
    //   beforeEnter: (_to: any, _from: any, next: any) => {
    //   const store = loginStore()
    //   const { token } = storeToRefs(store)
    //   token.value ? next('/user') : next()
    // }
  },
  ...newsRoutes,
  // append new router
]

const router = createRouter({
  routes,
  history: createWebHashHistory()
})

export default router